#pragma once

#include <pthread.h>

#include "config.h"

class Thread
{
	friend void* thread_fun(void *arg);
	friend class ThreadPool;

public:

	int Start();
	int Stop();
	bool IsStopped() const 	{ return _is_stopped; }
	pthread_t GetID() const { return _id; }

protected:	

	Thread():_is_stopped(true) {}
	virtual ~Thread() {}

protected:

	virtual int _Prepare() = 0;
	virtual int _Kernel() = 0;
	virtual int _Finish() =0;

private:

	void _Run();

private:

	pthread_t _id;
	volatile bool _is_stopped;
};

typedef std::vector<Thread*> ThreadVectorType;